home *** CD-ROM | disk | FTP | other *** search
- Path: news.mira.net.au!news
- From: davidw@werple.net.au (David White)
- Newsgroups: comp.lang.c++
- Subject: Re: Is there a standard for * and & placement style?
- Date: 27 Feb 1996 21:37:52 +1100
- Organization: Werple Internet, Melbourne
- Message-ID: <4gumu0$7c9@werple.net.au>
- References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com> <4gckd5$bc7@clarknet.clark.net> <marnoldDn63vB.H6n@netcom.com> <4gk1b8$mtm@werple.net.au> <marnoldDn9u0A.GAD@netcom.com>
- NNTP-Posting-Host: werple.mira.net.au
-
- marnold@netcom.com (Matt Arnold) writes:
-
-
- >...is a "special case" for the "char *"-style, simply highlights that the
- >style, IMO, is conceptually inconsistent. Certainly, the function itself
- >doens't have pointer-ness (although, as for as the language it concerned, it
- >resovles to an expression that does) and so it doesn't seem quite right to
- >associate the * with the function name. It seems inconsistent that you
- >would make this concession, but turn around and insist the "char *p" makes
- >sense for the declaration of p.
-
- It wasn't a concession. I would use 'char *foo()'. I was just saying that
- I can understand why some people prefer 'char* foo()' (and 'char* p').
-
- I don't want to drag this on, because it doesn't bother me if others use
- the 'char* p' form, but I don't think my point came across too well.
- My main point concerned you and another poster suggesting that the form:
- char* p, q;
- should declare both 'p' and 'q' to be char*. I was just trying to demonstrate
- that, without making special rules for '*' (and '&'), this doesn't fit in
- with the language. As far as the compiler is concerned, *, &, [],
- () are operators that apply to an operand. In its parsing, it treats
- them that way whether it is an expression or a declaration. It is only
- because '*' happens to be a pre-operand operator that you are able
- to place the '*' with the 'char'. That's why I prefer the 'char *p'
- (and 'char *foo()') form; I just follow the same rules as the compiler
- for everything. I don't see any fundamental difference between
- 'array of char' and 'pointer to char'; arrays and pointers are both
- types derived from some other, but you can't write 'char[10] p', simply
- because the [10] is on the wrong side of 'p'.
-
- David White
- davidw@werple.mira.net.au
-
-